﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class InvMovementService : IInvMovementService
    {
        public string AllocateMovement(string movementID, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new MovementBLL(pubParasInfo).AllocateMovement(movementID);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_AllocateMovement", movementID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return strTemp;
        }

        public string DeleteMovement(List<string> IDS, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new MovementBLL(pubParasInfo).Delete(IDS);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_DeleteMovement", IDS, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return strTemp;
        }

        public string DeleteMovementDetail(string MovementID, List<string> IDS, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new MovementDetailBLL(pubParasInfo).DeleteMovement(MovementID, IDS);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_DeleteMovementDetail", MovementID, IDS, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return strTemp;
        }

        public MovementDetailInfo GetAllMovementDetailByID(string MovementID, string ListID, PubParasInfo pubParasInfo)
        {
            try
            {
                MovementDetailBLL movementDetailBLL = new MovementDetailBLL(pubParasInfo);
                return movementDetailBLL.GetAllMovementDetailByID(MovementID, ListID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return null;
        }

        public DataSet GetMovementAllInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                MovementBLL movementBLL = new MovementBLL(pubParasInfo);
                return movementBLL.GetMovementAllInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return null;
        }

        public MovementInfo GetMovementInfoByID(string id, PubParasInfo pubParasInfo)
        {
            try
            {
                MovementBLL movementBLL = new MovementBLL(pubParasInfo);
                return movementBLL.GetInfoByID(id);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return null;
        }

        public DataSet GetMovementInfoByQueryEntity(MovementQueryEntity movementQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                MovementBLL movementBLL = new MovementBLL(pubParasInfo);
                return movementBLL.GetInfoByQueryEntity(movementQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return null;
        }

        public string InsertMovement(MovementInfo movementInfo, PubParasInfo pubParasInfo)
        {
            string MovementID = string.Empty;
            try
            {
                MovementID = new MovementBLL(pubParasInfo).Insert(movementInfo);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_InsertMovement", movementInfo, pubParasInfo);
                return MovementID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return MovementID;
        }

        public string InsertMovementDetail(MovementDetailInfo obj, PubParasInfo pubParasInfo)
        {
            string MovementID = string.Empty;
            try
            {
                MovementID = new MovementDetailBLL(pubParasInfo).InsertMovementDetail(obj);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_InsertMovementDetail", obj, pubParasInfo);
                return MovementID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return MovementID;
        }

        public string MovementConfirm(string movementID, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new MovementBLL(pubParasInfo).MovementConfirm(movementID);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_MovementConfirm", movementID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return strTemp;
        }

        public string RevertAllocateMovement(string movementID, PubParasInfo pubParasInfo)
        {
            string strTemp = string.Empty;
            try
            {
                strTemp = new MovementBLL(pubParasInfo).RevertAllocateMovement(movementID);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_AllocateMovement", movementID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return strTemp;
        }

        public string UpdateMovement(MovementInfo movementInfo, PubParasInfo pubParasInfo)
        {
            string MovementID = string.Empty;
            try
            {
                MovementID = new MovementBLL(pubParasInfo).Update(movementInfo);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_UpdateMovement", movementInfo, pubParasInfo);
                return MovementID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return MovementID;
        }

        public string UpdateMovementDetail(MovementDetailInfo obj, PubParasInfo pubParasInfo)
        {
            string MovementID = string.Empty;
            try
            {
                MovementID = new MovementDetailBLL(pubParasInfo).UpdateMovementDetail(obj);
                new OperationLogBLL(pubParasInfo).Insert("InvMovementService_UpdateMovementDetail", obj, pubParasInfo);
                return MovementID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InvMovementService异常");
            }
            return MovementID;
        }
    }
}

